﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Tdb.YY.BLL;
using Tdb.YY.DTO;
using Tdb.YY.DTO.Account;
using Tdb.YY.API.Extensions;

namespace Tdb.YY.API.Controllers
{
    /// <summary>
    /// 账号
    /// </summary>
    public class AccountController : BaseController
    {
        #region 变量

        /// <summary>
        /// 账号 逻辑层
        /// </summary>
        private AccountBLL bll = new AccountBLL();

        #endregion

        #region 接口

        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="req">登录参数</param>
        /// <returns></returns>
        [HttpPost]
        [AllowAnonymous]
        [Route("Login")]
        public ResultInfo<string> Login([FromBody]LoginReq req)
        {
            //获取客户端IP
            var ip = this.HttpContext.GetClientIp();

            return this.bll.Login(req.Password, ip);
        }

        #endregion
    }
}